<template>
  <custom-container>
    <el-table
      :data="tableData.list"
      :loading="loading" element-loading-text="加载中..." border border-radius
      height="385px"
    >
      <el-table-column
        align="center"
        prop="date"
        label="日期">
      </el-table-column>
      <el-table-column
        align="center"
        prop="day"
        label="新增用户">
      </el-table-column>
      <el-table-column
        align="center"
        label="1天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[0]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="2天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[1]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="3天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[2]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="4天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[3]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="5天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[4]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="6天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[5]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="7天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[6]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="14天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[7]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        label="30天后">
        <template slot-scope="{row}">
          {{_result(row, 'num[8]') | toShow(row, type)}}
        </template>
      </el-table-column>
      <template slot="empty">
        <div class="el-table__empty">
          <svg-icon class="el-table__empty-icon" icon-class="grid-empty-2"></svg-icon>
          <div class="el-table-text">暂无数据</div>
        </div>
      </template>
    </el-table>
  </custom-container>
</template>

<script>


  export default {
    name: "retain-table",

    props: ['tableData', 'loading', 'type'],

    filters: {
      toShow(value, row, type) {
        if (type === 'num') {
          return value;
        } else {
          if (value === null) {
            return '';
          } else {
            if (row.day === 0) {
              return '0.00%';
            } else {
              return `${_.formatDiv(value * 100, row.day, {fixed: 2})}%`;
            }
          }
        }
      }
    },

    data() {
      return {
      };
    }
  }
</script>

<style lang="scss" scoped>
</style>
